﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Maticsoft.DBUtility;

namespace CustomsSystem.DAL
{
    public class DBBackupServier
    {
    
        public DBBackupServier()
        {}
        public bool BackUp(string BKpath,string BKLOGpath)
        {
            StringBuilder sql =new StringBuilder();
            sql.Append( "BACKUP DATABASE Customs to DISK ='" + BKpath + "' ;");
            sql.Append("BACKUP LOG Customs TO DISK= '"+BKLOGpath+"' With No_Truncate");
            if(DbHelperSQL.ExecuteSql(sql.ToString())==0)
            {
                return false;
            }
            else
            {
                return true;
            }
        }
        public bool ResDB(string path)
        {
            string sql="Alter Database Customs Set Offline With Rollback Immediate;Use Master Restore Database Customs From Disk=N'" + path + "' WITH REPLACE;Alter  Database  Customs  Set   Online";
            if(DbHelperSQL.ExecuteSql(sql)==0)
            {
                return false;
            }
            else
            {
                return true;
            }
        }


    }
}
